package com.delivery.controller.admin;

import com.delivery.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {

    private final static String SHOP_STATUS = "shop_status";

    @Autowired
    RedisTemplate redisTemplate;
    @GetMapping("/status")
    public Result<Integer> getStatus() {

        Integer status = (Integer) redisTemplate.opsForValue().get(SHOP_STATUS);
        return Result.success(status);

    }

    @PutMapping("/{status}")
    public Result setStatus(@PathVariable Integer status) {

        redisTemplate.opsForValue().set(SHOP_STATUS, status);
        return Result.success();

    }

}
